<template>
  <u-popup :show="show" round="10px" @close="cancel" :closeOnClickOverlay="true" bgColor="transparent" mode="center">
    <div class="jfjlPopup">
      <div class="bc">
        <image src="/static/images/common/jfjl.png" mode="scaleToFill" />
      </div>
      <div class="content">
        <div class="title">
          <text class="t1">每一位新餐友点击授权使用，获得</text>
          <text class="t2">2积分</text>
          <text class="t1">。</text>
        </div>
        <div class="title2">即可免费查看2个电话，可叠加。</div>
        <button class="shareBtn" type="default" data-name="shareBtn" open-type="share">
          <image src="/static/images/common/qfx.png" mode="scaleToFill" />
        </button>
      </div>
    </div>
    <image @click="$emit('close')" class="close" src="/static/images/common/close.png" mode="scaleToFill" />
  </u-popup>
</template>

<script>
export default {
  name: "jfjlPopup",
  props: {},
  data() {
    return {
      show: false,
      isLogin: false,
      phone: "",
      userStatus: null, //resume_status,job_status
    };
  },
  computed: {},
  methods: {
    async submit() {
      this.$emit("submit");
    },
    cancel() {
      this.$emit("cancel");
    },
    clickItem(type, type2) {
      switch (type) {
        case 1:
          if (type2 == "gl") {
            this.$togo("/pages2/regulateJobs");
          } else {
            this.$togo("/pages2/postOffer", { phone: this.phone });
          }

          break;
        case 2:
          if (type2 == "gl") {
            this.$togo("/pages2/regulateResume");
          } else {
            this.$togo("/pages2/postRecruitmentInformation", { phone: this.phone });
          }

          break;
        case 3:
          this.$layer.message("功能正在开发中,敬请期待...");
          break;
        case 4:
          this.$layer.message("功能正在开发中,敬请期待...");
          break;
        case 5:
          this.$layer.message("功能正在开发中,敬请期待...");
          break;
      }
      this.$emit("cancel");
    },
    getPhoneNumber1(e) {
      uni.login({
        provider: "weixin",
        success: async res => {
          this.code = res.code;
          // console.log(res);
          let res2 = await this.$http.requestSync("/wechat/login", { code: e.detail.code, loginCode: res.code });
          console.log(res2.header);
          this.$layer.message(res2.data.user_info.phone);
          this.$setStoraged("phone", res2.data.user_info.phone);
          this.$setStoraged("user_id", res2.data.user_info.id);
          this.$setStoraged("authration_token", res2.data.token);
          this.$setStoraged("open_id", res2.data.user_info.wechart_open_id);
          this.$togo("/pages2/postOffer", { phone: res2.data.user_info.phone });
        },
      });
    },
    getPhoneNumber2(e) {
      uni.login({
        provider: "weixin",
        success: async res => {
          this.code = res.code;
          // console.log(res);
          let res2 = await this.$http.requestSync("/wechat/login", { code: e.detail.code, loginCode: res.code });
          console.log(res2.header);
          this.$layer.message(res2.data.user_info.phone);
          this.$setStoraged("phone", res2.data.user_info.phone);
          this.$setStoraged("user_id", res2.data.user_info.id);
          this.$setStoraged("authration_token", res2.data.token);
          this.$setStoraged("open_id", res2.data.user_info.wechart_open_id);
          this.$togo("/pages2/postRecruitmentInformation", { phone: res2.data.user_info.phone });
        },
      });
    },
    // 查询用户是否发布过求职和招聘
    async getUserStatus() {
      let res = await this.$http.requestSync("/user/status");
      if (res.code == 200) {
        this.userStatus = res.data;
        console.log("getUserStatusgetUserStatusgetUserStatus", res);
      }
    },
    showModal() {
      this.show = true;
    },
    hideModal() {
      this.show = false;
    },
  },
  watch: {},
  created() {
    if (this.$getStoraged("phone").length > 0) {
      this.isLogin = true;
      this.phone = JSON.parse(this.$getStoraged("phone"));
      this.getUserStatus();
    } else {
      this.isLogin = false;
    }
  },
  // 组件周期函数--监听组件挂载完毕
  mounted() {},
  // 组件周期函数--监听组件数据更新之前
  beforeUpdate() {},
  // 组件周期函数--监听组件数据更新之后
  updated() {},
  // 组件周期函数--监听组件激活(显示)
  activated() {},
  // 组件周期函数--监听组件停用(隐藏)
  deactivated() {},
  // 组件周期函数--监听组件销毁之前
  beforeDestroy() {},
};
</script>

<style scoped lang="scss">
.jfjlPopup {
  width: 260px;
  height: 277px;
  .bc {
    width: 260px;
    height: 277px;
    image {
      width: 260px;
      height: 277px;
      position: relative;
      z-index: 0;
    }
  }
  .content {
    position: absolute;
    z-index: 2;
    top: 113px;
    left: 22px;
    right: 22px;
    .title {
      font-size: 14px;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: #333333;
      line-height: 22px;
      .t2 {
        color: #ff8822;
      }
    }
    .title2 {
      font-size: 14px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #333333;
      margin: 18px auto 20px;
    }
    .shareBtn {
      width: 100%;
      height: 43px;
      image {
        width: 100%;
        height: 100%;
      }
    }
    button {
      border: none;
      background: transparent;
      padding: 0px;
    }
  }
}
.close {
  width: 23px;
  height: 23px;
  margin: 10px auto;
}
</style>
